#! /usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2020-11-07 19:16
# @Author : youngchaolin

# 参考上节课的记录

# pickle的dumps和loads只能用于网络传输

# 多次写入和读取
def func1():
    print('i am func1')


def func2():
    print('i am func2')


def func3():
    print('i am func3')


f = open('funcs', mode='wb')
import pickle

# 多次写入文件
pickle.dump(func1, f)
pickle.dump(func2, f)
pickle.dump(func3, f)
f.close()

# 多次读取文件
f1 = open('funcs', mode='rb')
while 1:
    try:
        ret = pickle.load(f1)
        print(ret)
        # 执行ret
        ret()
    except EOFError:
        break
f1.close()

# 太白金星博客流程图
# https://www.cnblogs.com/jin-xin/articles/10899787.html
